/**
 * @author tmh
 * @date 2024/9/24 20:04
 * @description
 */
public class T45跳跃游戏II {
    public int jump(int[] nums) {
        int step = 0;
        int maxPosition = 0;
        int end = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            maxPosition = Math.max(maxPosition, i + nums[i]);
            if (i == end) {
                end = maxPosition;
                step++;
            }
        }
        return step;
    }
}
